package com.esri.core.internal.io.handler;

import com.esri.core.io.EsriSecurityException;
import com.esri.core.io.UserCredentials;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.security.KeyStore;

/* loaded from: classes.dex */
public class o implements Serializable {
    private static KeyStore g = null;
    private static final long serialVersionUID = 5661154003751399898L;
    protected String a;
    protected boolean b;
    private String c;
    private String d;
    private String e;
    private String f;
    private UserCredentials.AuthenticationType h;
    private long i;
    private String j;

    public o() {
        this.a = null;
        this.c = null;
        this.d = null;
        this.e = null;
        this.f = null;
        this.h = null;
        this.j = "";
    }

    public o(o oVar) {
        this.a = null;
        this.c = null;
        this.d = null;
        this.e = null;
        this.f = null;
        this.h = null;
        this.j = "";
        if (oVar != null) {
            this.d = oVar.d;
            this.a = oVar.a;
            this.c = oVar.c;
            this.e = oVar.e;
            this.i = oVar.i;
            this.f = oVar.f;
            this.b = oVar.b;
            this.h = oVar.h;
            this.j = oVar.j;
        }
    }

    public o a() {
        return new o(this);
    }

    public static void a(KeyStore keyStore) throws EsriSecurityException {
        a((KeyStore) null, (String) null, keyStore);
    }

    public static void a(KeyStore keyStore, String str, KeyStore keyStore2) throws EsriSecurityException {
        g = keyStore2;
        c.a(keyStore, str, keyStore2);
    }

    public String b() {
        return this.j;
    }

    public void a(String str) {
        this.j = str;
    }

    public void a(String str, String str2) {
        if (this.d != null) {
            System.err.println("Credentials have been set with a token. Username and password will not be applied. Please create a new credentials object and set username and password on it.");
        } else if (str == null || str.trim().length() == 0 || str2 == null || str2.trim().length() == 0) {
            throw new IllegalArgumentException("Username and password must be non-empty strings");
        } else {
            this.a = str;
            this.c = str2;
        }
    }

    public void b(String str) {
        if (str == null || str.trim().length() == 0) {
            throw new IllegalArgumentException("Username and password must be non-empty strings");
        }
        this.a = str;
    }

    public void b(String str, String str2) {
        a(str, -1L, str2);
    }

    public void a(String str, long j, String str2) {
        if (str == null || str.trim().length() == 0 || str2 == null || str2.trim().length() == 0) {
            throw new IllegalArgumentException("Token and referer must be a non-empty string");
        }
        this.d = str;
        this.f = str2;
        this.i = j;
    }

    public void c(String str) {
        if (str == null || str.trim().length() == 0) {
            throw new IllegalArgumentException("Token service URL is invalid " + str);
        }
        this.e = str;
    }

    public String c() {
        return this.d;
    }

    public long d() {
        return this.i;
    }

    public String e() {
        return this.f;
    }

    public String f() {
        return this.e;
    }

    public String g() {
        return this.a;
    }

    public String h() {
        return this.c;
    }

    public boolean i() {
        return this.b;
    }

    public void a(boolean z) {
        this.b = z;
    }

    public static UserCredentials.AuthenticationType d(String str) {
        return c.d(str);
    }

    public UserCredentials.AuthenticationType j() {
        return this.h;
    }

    public void a(UserCredentials.AuthenticationType authenticationType) {
        this.h = authenticationType;
    }

    public boolean k() {
        String str = this.a;
        if (str == null || str.trim().length() <= 0) {
            String str2 = this.d;
            return str2 == null || str2.trim().length() <= 0;
        }
        return false;
    }

    public int hashCode() {
        int i = ((this.b ? 1231 : 1237) + 31) * 31;
        String str = this.j;
        int hashCode = (i + (str == null ? 0 : str.hashCode())) * 31;
        String str2 = this.f;
        int hashCode2 = (hashCode + (str2 == null ? 0 : str2.hashCode())) * 31;
        String str3 = this.d;
        int hashCode3 = str3 == null ? 0 : str3.hashCode();
        long j = this.i;
        int i2 = (((hashCode2 + hashCode3) * 31) + ((int) (j ^ (j >>> 32)))) * 31;
        String str4 = this.e;
        int hashCode4 = (i2 + (str4 == null ? 0 : str4.hashCode())) * 31;
        UserCredentials.AuthenticationType authenticationType = this.h;
        int hashCode5 = (hashCode4 + (authenticationType == null ? 0 : authenticationType.hashCode())) * 31;
        String str5 = this.c;
        int hashCode6 = (hashCode5 + (str5 == null ? 0 : str5.hashCode())) * 31;
        String str6 = this.a;
        return hashCode6 + (str6 != null ? str6.hashCode() : 0);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            o oVar = (o) obj;
            if (this.b != oVar.b) {
                return false;
            }
            String str = this.j;
            if (str == null) {
                if (oVar.j != null) {
                    return false;
                }
            } else if (!str.equals(oVar.j)) {
                return false;
            }
            String str2 = this.f;
            if (str2 == null) {
                if (oVar.f != null) {
                    return false;
                }
            } else if (!str2.equals(oVar.f)) {
                return false;
            }
            String str3 = this.d;
            if (str3 == null) {
                if (oVar.d != null) {
                    return false;
                }
            } else if (!str3.equals(oVar.d)) {
                return false;
            }
            if (this.i != oVar.i) {
                return false;
            }
            String str4 = this.e;
            if (str4 == null) {
                if (oVar.e != null) {
                    return false;
                }
            } else if (!str4.equals(oVar.e)) {
                return false;
            }
            if (this.h != oVar.h) {
                return false;
            }
            String str5 = this.c;
            if (str5 == null) {
                if (oVar.c != null) {
                    return false;
                }
            } else if (!str5.equals(oVar.c)) {
                return false;
            }
            String str6 = this.a;
            if (str6 == null) {
                if (oVar.a != null) {
                    return false;
                }
            } else if (!str6.equals(oVar.a)) {
                return false;
            }
            return true;
        }
        return false;
    }

    public String toString() {
        return "UserCredentials [Username=" + this.a + "]";
    }

    private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
        objectOutputStream.writeBoolean(this.b);
        objectOutputStream.writeLong(this.i);
        objectOutputStream.writeObject(this.f);
        objectOutputStream.writeObject(this.d);
        objectOutputStream.writeObject(this.e);
        objectOutputStream.writeObject(this.h);
        objectOutputStream.writeObject(this.j);
        objectOutputStream.writeObject(this.c);
        objectOutputStream.writeObject(this.a);
    }

    private void readObject(ObjectInputStream objectInputStream) throws ClassNotFoundException, IOException {
        if (UserCredentials.isDefaultReadObject()) {
            objectInputStream.defaultReadObject();
            return;
        }
        this.b = objectInputStream.readBoolean();
        this.i = objectInputStream.readLong();
        this.f = (String) objectInputStream.readObject();
        this.d = (String) objectInputStream.readObject();
        this.e = (String) objectInputStream.readObject();
        this.h = (UserCredentials.AuthenticationType) objectInputStream.readObject();
        this.j = (String) objectInputStream.readObject();
        this.c = (String) objectInputStream.readObject();
        this.a = (String) objectInputStream.readObject();
    }
}
